from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModPowerSupplyStationList import PowerSupplyStationList,stationListSchema
from database import Session, engine
import datetime
from dao import DaoPowerSupplyStationList
from dao import DaoWorkRecord


class PowerSupplyStationListAll(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
           bureauid = request.query_params["bureauid"]
           return  DaoPowerSupplyStationList.get_station_info_all(session, bureauid)
        finally:
            session.close()


class PowerSupplyStationListSingle(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
           bureauid = request.query_params["bureauid"]
           stationid=request.query_params["stationid"]
           return  DaoPowerSupplyStationList.get_station_info_single(session, bureauid, stationid)
        finally:
            session.close()